package com.ssm.gbq.dao.impl;

import com.ssm.gbq.dao.OrderDao;
import com.ssm.gbq.mapper.OrderMapper;
import com.ssm.gbq.model.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrderDaoImpl implements OrderDao {

    @Autowired
    private OrderMapper orderMapper;

    /**
     * 插入订单数据
     * @param order 订单数据
     * @return
     */
    public Integer insert(Order order) {

        Integer rows = orderMapper.insert(order);
        return rows;
    }

    /**
     * 根据订单id删除id
     * @param id 订单id
     * @return
     */
    public Integer deleteById(Integer id) {
        Integer rows = orderMapper.deleteById(id);
        return rows;
    }

    /**
     * 根据订单id更改订单数据
     * @param order
     * @return
     */
    public Integer updateById(Order order) {
        return orderMapper.updateById(order);
    }

    /**
     * 获取所有的订单信息
     * @return 所有的订单信息
     */
    public List<Order> findAll() {
        List<Order> list = orderMapper.findAll();

        return list;
    }

    public List<Order> openOrderTable(Integer currentPage, Integer pageSize) {

        List<Order> list = orderMapper.selectByLimitPage(currentPage,pageSize);
        return list;
    }

    /**
     * 根据名字查询订单信息(模糊查询)
     * @param name
     * @return 返回订单列表
     */
    public List<Order> selectByName(String name) {
        return orderMapper.selectByName(name);
    }

}
